package com.cnap.multiclouldmgmt.controller;

import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSONObject;
import com.cnap.multiclouldmgmt.model.CommonResult;
import com.cnap.multiclouldmgmt.model.RepByPage;
import com.cnap.multiclouldmgmt.model.ReqPageModel;
import com.cnap.multiclouldmgmt.model.gpu.MicroSvcGpuInfoModel;
import com.cnap.multiclouldmgmt.model.gpu.NodeQueryModel;
import com.cnap.multiclouldmgmt.model.network.LinkResInfoModel;
import com.cnap.multiclouldmgmt.model.vm.*;
import com.cnap.multiclouldmgmt.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * 对接其他后端相关系统
 * @author dyq
 */
@Api(tags ="网络资源相关")
@RequestMapping(path = "/cnap/multicloudmgmt/v1/newwork")
@RestController
@ResponseBody
public class NetworkController {

    private final static Logger LOGGER = LoggerFactory.getLogger(NetworkController.class);

    @Autowired
    private NetworkInfoService networkInfoService;

    /**
     *获取网络资源监控信息
     * @return
     */
    @ApiOperation(value = "11-1 获取网络资源监控信息",httpMethod = "POST",
            notes = "")
    @RequestMapping(path = "/getLinkResInfo",method = RequestMethod.POST)
    public CommonResult<RepByPage<LinkResInfoModel>> getLinkResInfo(@RequestBody ReqPageModel reqPageModel) {

        try {

            return CommonResult.success(networkInfoService.getLinkResInfo(reqPageModel.getPageSize(),
                    reqPageModel.getPageNo()));

        }catch (Exception e){

            LOGGER.error("NetworkController getLinkResInfo error",e);

            return CommonResult.failed(e.getMessage());
        }
    }

}
